<?php
/**
 * 荣誉类
 * @author  zhanghui
 * @create_date 2008-02-28
 */
class Honour{
	function __construct(){}
	function __destruct(){}
	
	/* 新加荣誉记录
	 * @param $conn 数据库连接类
	 * @param : array $arr_input - baby_id,postid,title,content,file_server,file_name,create_date
	 */
	function addHonour($conn,$arr_input){
		$str_query = "insert into";
		$str_query .= " baby_honour";
		$str_query .= " set";
		$str_query .= " baby_id={$arr_input['baby_id']}";
		$str_query .= ",title='{$arr_input['title']}'";
		$str_query .= ",content='{$arr_input['content']}'";
		$str_query .= ",file_server='{$arr_input['file_server']}'";
		$str_query .= ",file_name='{$arr_input['file_name']}'";
		$str_query .= ",create_date='".$conn->getCurrentTime()."'";
		
		$conn->executeQuery($str_query);
	}
	
	/* 获取荣誉记录 
	 * @param $conn 数据库连接类
	 * @param : array $arr_input - baby_id,postid,title,content,file_server,file_name,create_date
	 * @param string $limit 
     * @return : $arr_output
     *			baby_id, 			[0]<br>
     *			postid, 		    [1]<br>
     *			title, 			    [2]<br>
     *			content, 		    [3]<br>
     *			file_server, 	    [4]<br>
     *			file_name, 		    [5]<br>
     *			create_date, 		[6]<br>
	 */
	function getHonourList($conn,$arr_input,$limit = null){
		$str_query = "select";
		if(isset($arr_input['cnt'])){
			$str_query .= " count(1)";
		}else{
			$str_query .= " baby_id";
			$str_query .= ",postid";
			$str_query .= ",title";
			$str_query .= ",content";
			$str_query .= ",file_server";
			$str_query .= ",file_name";
			$str_query .= ",create_date";
		}
		$str_query .= " from";
		$str_query .= " baby_honour";
		$str_query .= " where";
		$str_query .= " baby_id={$arr_input['baby_id']}";
		if(isset($arr_input['postid'])){
			$str_query .= " and postid={$arr_input['postid']}";
		}		
		if (isset($arr_input['orderby'])) {
        	$str_query .= " order by {$arr_input['orderby']}";
        }
        if ($limit != null){
        	$str_query .= " {$limit}";
        }
		
		$arr_output = $conn->selectQuery($str_query);
        return $arr_output;
	}
	
}
?>